<%@ page import="static com.suyeer.consumer.util.ConstUtil.SYSTEM_START_UP_TIME" %>
<%--
  Created by IntelliJ IDEA.
  User: jun
  Date: 2017/3/15
  Time: 下午11:01
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="shortcut icon" href="/img/common/favicon.ico"/>
    <link rel="bookmark" href="/img/common/favicon.ico"/>
    <link rel="stylesheet" href="/css/common/base.css?v=<%=SYSTEM_START_UP_TIME %>"/>
    <style>
        body {
            background-color: #ccc;
        }

        .login-wrap {
            width: 600px;
            height: 300px;
            margin: 150px auto 100px;
            background-color: #fafafa;
            overflow: inherit;
            border-radius: 5px;
        }

        .login-title {
            width: 100%;
            height: 30px;
            margin: 30px auto 10px;
            text-align: center;
            font-size: 20px;
            font-weight: 400;
            color: #000;
        }

        .input-wrap {
            width: 300px;
            height: 200px;
            margin: 10px auto;

        }

        .input-holder {
            width: 300px;
            height: 40px;
            margin: 5px auto;
            padding: 0px 5px;
            font-size: 18px;
            border-radius: 3px;
            border: solid 1px #ccc;
        }

        ::-webkit-input-placeholder {
            font-size: 18px;
            line-height: 40px;
        }

        .btn {
            background-color: #1f96e0;
            color: #fff;
            cursor: pointer;
        }

        .btn:hover {
            background-color: #2b4490;
            transition: background-color .5s;
        }

        .btn:active {
            background-color: #1f96e0;
        }

        .header {
            position: fixed;
            width: 100%;
            height: 60px;
            background-color: #1f2222;

        }

        .nav-wrap {
            min-width: 800px;
            max-width: 1000px;
            height: 60px;
            margin: 0 auto;
        }

        .logo-wrap {
            float: left;
            width: 400px;
            height: 60px;
            font-size: 38px;
            font-weight: 500;
            line-height: 50px;
            text-align: center;
        }

        .logo {
            font-family: "Songti TC";
            color: #7bbfea;
        }

        .logo:hover {
            color: white;
            transition: color .6s;
        }

    </style>
</head>
<body>
<div class="header">
    <div class="nav-wrap">
        <div class="logo-wrap">
            <span class="logo">Spring MVC Frame</span>
        </div>
    </div>
</div>
<div class="login-wrap">
    <div class="login-title">
        <span>登录</span>
    </div>
    <div class="input-wrap">
        <input class="input-holder j_user_id" type="text" placeholder="邮箱或手机号" value="suyeer">
        <input class="input-holder j_user_password" type="password" placeholder="密码" value="123456">
        <input class="input-holder btn j_login_btn" type="button" value="登  录">
    </div>
</div>
<script src="/js/common/jquery.1.11.3.min.js"></script>
<script src="/js/common/jweixin-1.2.1.js"></script>
<script src="/js/common/md5.min.js"></script>
<script src="/js/common/google-analytics.js"></script>
<script type="text/javascript">
    var GData = {};
    var GFunc = {
        onKeyDown: function () {
            document.onkeydown = function (event) {
                var e = event || window.event || arguments.callee.caller.arguments[0];
                if (e && e.keyCode == 13) { // enter 键
                    if (GFunc.checkEmpty()) {
                        GFunc.doLogin();
                    }
                }
            };
        },
        bind: function () {
            $('.j_login_btn').click(function () {
                if (GFunc.checkEmpty()) {
                    GFunc.doLogin();
                }
            });
        },
        checkEmpty: function () {
            var userId = $('.j_user_id').val();
            var userPassword = $('.j_user_password').val();
            if (userId == '') {
                alert('请输入用户名');
                return false;
            }
            if (userPassword == '') {
                alert('请输入密码');
                return false;
            }
            return true;
        },
        doLogin: function () {
            var data = {
                userId: $('.j_user_id').val(),
                userPwd: md5($('.j_user_password').val()),
            };
            $.post('/login.do', data, function (data) {
                if (data.code == 200) {
                    window.location.href = GFunc.getBackUrl();
                } else {
                    alert(data.message);
                }
            });
        },
        getBackUrl: function () {
            var reg = new RegExp("(^|&)backUrl=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            return (r != null ? decodeURIComponent(r[2].toLowerCase()) : "/");
        },
    };
    $(function () {
        GFunc.bind();
        GFunc.onKeyDown();
    });
</script>
</body>
</html>
